package com.spring.boot.core.utils;

import java.util.regex.Pattern;

public class RegexUtils {
	private static final Pattern account_pattern = Pattern.compile("[A-Z0-9a-z._%+-]{4,32}");
	private static final Pattern email_pattern = Pattern.compile("[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}");
	private static final Pattern phone_pattern = Pattern.compile("1[1-9][0-9]{9}");
	private static final Pattern password_pattern = Pattern.compile("[A-Z0-9a-z~`!@#$%^&*()_=+{}|;:'\"<,>.?/\\\\\\[\\]-]{4,32}");
	
	public static boolean isAccount(String account) {
		return account_pattern.matcher(account).matches();
	}
	
	public static boolean isEmail(String email) {
		return email != null && email.length() < 128 && email_pattern.matcher(email).matches();
	}
	
	public static boolean isPhone(String phone) {
		return phone_pattern.matcher(phone).matches();
	}
	
	public static boolean isPassword(String password) {
		return password_pattern.matcher(password).matches();
	}
	
	public static void main(String[] args) {
//		System.out.println(isEmail("bigbea.xr@hel.edu.cn"));
//		System.out.println(isPhone("10345678900"));
//		System.out.println(isAccount("1234"));
		System.out.println(isPassword("~`!@#$%^&*()_=+-{}|;:'\"<,>.?/\\[]"));
	}
}
